#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
#include <QLabel>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QLabel * label = new QLabel("文件路径：",this);
    ui->statusBar->addWidget(label);
    QLabel * label2 = new QLabel("起始时间",this);
    ui->statusBar->addPermanentWidget(label2);

    connect(ui->actionOpen,&QAction::triggered, this, [=](){
        QString strs;
        QStringList file_list, output_name;
        QStringList str_path_list = QFileDialog::getOpenFileNames(this, "打开文件", "C:/Users/62320/Desktop", tr("(*.txt)"));
        QString dir_path_list = QFileDialog::getExistingDirectory(this, "选择文件夹", "./");
        qDebug()<<dir_path_list;
        for (int i = 0; i < str_path_list.size(); i++){
            QString str_path = str_path_list[i];
            //单个文件路径
            qDebug() << "path=" << str_path;
            QFileInfo file = QFileInfo(str_path);
            //获得文件名
            QString file_name = file.fileName();
            file_list.append(str_path);
            output_name.append(file_name);
            strs.append(file_name);
            strs += "\n";
        }

        qDebug()<<strs;
        qDebug()<<file_list;
        qDebug()<<output_name;
        qDebug()<<str_path_list;


        label->setText(" = QLabel(文件路径：,this);");
        label2->setText("起始时间change");
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
